package com.example.demo.mapper;

import com.example.demo.pojo.Order;
import com.example.demo.pojo.OrderItem;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface OrderMapper {
	@Insert("INSERT INTO `order` (userID, orderNum, receiverName, receiverPhone, receiverAddress, orderStatus, totalPrice, createTime) " +
			"VALUES (#{userID},#{orderNum}, #{receiverName}, #{receiverPhone}, #{receiverAddress}, #{orderStatus}, #{totalPrice}, #{createTime})")
	void insert(Order order);

	@Select("SELECT * FROM `order` WHERE orderNum=#{orderNum}")
	Order findByOrderNo(String orderNum);

	@Update("UPDATE `order` SET orderStatus = #{orderStatus},payTime=#{payTime} WHERE orderNum=#{orderNum}")
	void updateByPrimaryKeySelective(Order order);


	@Select("SELECT orderNum, orderStatus FROM `order` WHERE userID = #{userID}")
	List<Order> selectOrderNumsAndStatusByUserId(Integer userID);

	@Select("SELECT orderNum FROM `order` WHERE userID = #{userID}")
	List<String> selectOrderNumsByUserId(Integer userID);


}
